Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add voice manager (ability to override voice chat / mute players) #179

Merged
merged 9 commits into from
Dec 12, 2023
Merged

Add voice manager (ability to override voice chat / mute players) #179

merged 9 commits into from
Dec 12, 2023

Conversation

Poggicek
Copy link
Contributor

@Poggicek Poggicek commented Dec 6, 2023

This PR implements a basic voice manager that exposes the ability to override the voice chat and specify who can hear who.
Waiting for alliedmodders/hl2sdk#182 to be accepted

Examples

Voice Flags

[ConsoleCommand("muteself")]
public void OnMuteSelfCommand(CCSPlayerController? caller, CommandInfo command)
{
    if (caller is null) return;

    caller.VoiceFlags = VoiceFlags.Muted;
    command.ReplyToCommand("Muted yourself");
}

Listen override

Native allowing you to specify who exactly a player can/cannot hear

[ConsoleCommand("muteothers")]
public void OnMuteOthersCommand(CCSPlayerController? caller, CommandInfo command)
{
    if (caller is null) return;

    foreach (var player in Utilities.GetPlayers())
    {
        if (player == caller) continue;
        
        caller.SetListenOverride(player, ListenOverride.Mute);
    }
}

Definitions

Flags

public enum VoiceFlags : Byte
{
    Normal = 0,
    Muted = (1 << 0),
    All = (1 << 1),
    ListenAll = (1 << 2),
    Team = (1 << 3),
    ListenTeam = (1 << 4),
}

Overrides

public enum ListenOverride
{
    Default = 0,
    Mute,
    Hear
}

@KillStr3aK
Copy link
Contributor

would be possible to listen to specific players only? maps used to have rooms where you could only hear the players that is also inside the room, aka voice rooms

@Poggicek
Copy link
Contributor Author

Poggicek commented Dec 7, 2023

That's already possible with SetListenOverride

@zonical
Copy link
Collaborator

zonical commented Dec 7, 2023

hl2sdk#182 has been merged, FYI.

@roflmuffin
Copy link
Owner

I've added a doc example for the voice methods, and also added GetListenOverride so you can check the listen override status for a given player and update accordingly.

@roflmuffin roflmuffin merged commit bff04e7 into roflmuffin:main Dec 12, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants